extern crate core;

use std::cell::UnsafeCell;
use std::future::Future;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
use std::task::{Context, Poll, Waker};
use std::time::Duration;
use std::{mem, thread};

use lazy_static::lazy_static;
use log::info;
use mini_redis::server::run;
use mini_redis::{client, Result};
use serde::__serialize_unimplemented;
use tokio::join;
use tokio::macros::support::thread_rng_n;
use tokio::runtime::Runtime;
use tokio::time::sleep;

use crate::config::ftlog_init;
use crate::cus_executor_future::time_future::TimeFuture;
use crate::utils::ThreadSafePtr;
use bytes::Bytes;
use std::num::ParseIntError;
use std::str;
use structopt::StructOpt;
mod advanced;
pub mod config;
mod cus_executor_future;
mod test;
mod utils;
mod cus_redis;

lazy_static! {
    pub static ref ROOT_APP_CONFIG: config::RootAppConfig =
        config::RootAppConfig::new("src/app.yml");
}


#[tokio::main(worker_threads = 4)]
pub async fn main() {
    ftlog_init(&ROOT_APP_CONFIG).unwrap();
    async fn do_reset(msg: &mut String) {
        *msg = "new".to_string();
    }
    async fn do_async(fut: impl Future<Output = ()>) {
        fut.await;
    }
    let mut fut = async {
        let mut msg = "this is a special msg".to_string();
        do_reset(&mut msg).await;
        println!("{}", msg);
    };
    unsafe {
        let read = std::ptr::read(&fut);
        do_async(read).await;
    }
}
